package mn.idax.exchange.otc.service.impl;

import mn.idax.exchange.otc.entity.OTCUser;
import mn.idax.exchange.otc.entity.OTCUserGroup;
import mn.idax.exchange.otc.entity.OTCUserGroupExample;
import mn.idax.exchange.otc.mapper.OTCUserGroupMapper;
import mn.idax.exchange.otc.service.OTCUserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Create by jack_huang on 2018/8/29
 */
@Service
public class OTCUserGroupServiceImpl implements OTCUserGroupService{

    @Autowired
    private OTCUserGroupMapper otcUserGroupMapper;

    //用户是否将另一个人加入过黑名单后者白名单 == null未加入过
    @Override
    public Boolean isContainedList(Integer creator, Integer userId, Integer type) {
        OTCUserGroupExample example = new OTCUserGroupExample();
        example.createCriteria().andCreatorEqualTo(creator)
                .andUseridEqualTo(userId)
                .andTypeEqualTo(type);
        List<OTCUserGroup> otcUserGroups = otcUserGroupMapper.selectByExample(example);

        return otcUserGroups.isEmpty();
    }
}
